package com.juzipi.demo.singleresponsibility;

public class SingleResponsibility3 {
    public static void main(String[] args) {
        Vehicle1 vehicle1 = new Vehicle1();
        vehicle1.run("汽车");
        vehicle1.runAir("飞机");
        vehicle1.runWater("轮船");

    }
}

//方式三的分析
//1.这种修改方法没有对原来的类做大的修改，只是增加方法
//2.这里虽然没有在类这个级别上遵守单一职责原则，但是在方法级别上任然是遵守单一职责原则
class Vehicle1 {
    public void run(String vehicle){
        System.out.println(vehicle+"在公路上运行");
    }

    public void runAir(String vehicle){
        System.out.println(vehicle+"在空中上运行");
    }

    public void runWater(String vehicle){
        System.out.println(vehicle+"在水中上运行");
    }
}